package com.hanbang.maige.mode.javabean.huodong;

import android.os.SystemClock;

import com.google.gson.annotations.Expose;
import com.hanbang.maige.mode.enumeration.HuoDongStatus;
import com.hanbang.maige.utils.other.DateUtils;
import com.hanbang.maige.utils.other.StringUtils;

/**
 * 作者　　: 李坤
 * 创建时间:2016/10/26　14:41
 * 邮箱　　：496546144@qq.com
 * <p>
 * 功能介绍：
 */

public class HuoDongItemData {

    /**
     * ActiveHaiBao :
     * ActiveHaiBaoMid : /upload/201610/27/middle/huodong/201610271614152805_Mid.jpg
     * ActiveHaiBaoSma : /upload/201610/27/small/huodong/201610271614152805_Sma.jpg
     * ActivityName : gg
     * NiChenName : mg162747
     * ActivityAddress : hhhh
     * ActiveJieShao : jjjj
     * Zhuangtai : 1
     * StartTime : /Date(1477555920000)/
     * ZhuangtaiCN : 进行中
     * Activedjs : 0
     */

    @Expose(deserialize = false)
    private long elapsedRealtime;
    @Expose(deserialize = false)
    private long differenceTime;

    private String ActivityID;
    private String ActiveHaiBaoMid;
    private String ActivityName;
    private String NiChenName;
    private String ActivityAddress;
    private String ActiveJieShao;
    private String StartTime;
    private String Endtime;
    private long Activedjs;


    public HuoDongItemData() {
        elapsedRealtime = SystemClock.elapsedRealtime();
    }

    public String getActiveHaiBaoMid() {
        return ActiveHaiBaoMid;
    }


    public String getActivityName() {
        return StringUtils.dataFilter(ActivityName);
    }


    public String getNiChenName() {
        return StringUtils.dataFilter(NiChenName);
    }


    public String getActivityAddress() {
        return StringUtils.dataFilter(ActivityAddress);
    }


    public String getActiveJieShao() {
        return StringUtils.dataFilter(ActiveJieShao);
    }

    public void setActiveJieShao(String ActiveJieShao) {
        this.ActiveJieShao = ActiveJieShao;
    }


    public String getStartTime() {
        return StartTime;
    }

    public String getEndtime() {
        return Endtime;
    }

    public void setStartTime(String StartTime) {
        this.StartTime = StartTime;
    }


    public long getActivedjs() {

        long difference = SystemClock.elapsedRealtime() - elapsedRealtime;
        return Activedjs - difference;
    }

    public void setActivedjs(int Activedjs) {
        elapsedRealtime = SystemClock.elapsedRealtime();
        this.Activedjs = Activedjs;
    }

    public String getActivityID() {
        return ActivityID;
    }

    public HuoDongStatus getHuoDongStatus() {
        if (differenceTime <= 0) {
            differenceTime = DateUtils.dateToLong(Endtime) - DateUtils.dateToLong(StartTime);
        }
        long djs = getActivedjs();
        if (djs > 0) {//倒计时大于0  代表活动没开始
            return HuoDongStatus.NO_START;
        } else if (Math.abs(djs) < differenceTime) {//倒计时绝对值 小于 开始时间与结束时间的差值    就是进行中
            return HuoDongStatus.ACTIONING;
        } else {//其他情况就是已经结束
            return HuoDongStatus.STOP;
        }


    }
}
